package com.lrkj.seetaface.controller;


import com.cnsugar.ai.face.SeetafaceBuilder;
import com.lrkj.seetaface.service.SeetFaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
 * seetface引擎人脸识别Controller
 *
 * @author wyd
 * @date 2022-07-13
 */
@Controller
@RequestMapping("/seetface")
public class SeetFaceController {

    @Autowired
    private SeetFaceService seetFaceService;


    //seetface模式接口
    @RequestMapping(value = "/faceimg", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public String getPicture(String  base64img) throws IOException {
        return  seetFaceService.faceDisplayImg(base64img);
    }

    //seet引擎初始化
    //@PostConstruct
    private void initseet() {
        SeetafaceBuilder.build();//系统启动时先调用初始化方法
        //等待初始化完成
      /*  while (SeetafaceBuilder.getFaceDbStatus() == SeetafaceBuilder.FacedbStatus.LOADING || SeetafaceBuilder.getFaceDbStatus() == SeetafaceBuilder.FacedbStatus.READY) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }*/
        System.out.println("seet初始化引擎成功");
    }
}
